<!--
 * @Author: your name
 * @Date: 2021-09-07 09:09:23
 * @LastEditTime: 2021-09-07 09:18:03
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day12\1-DOM节点操作.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>123</div>
</body>
<script>
    //1.创建一个div节点
    var myDiv = document.createElement('div');
    //2.给节点添加文本内容
    myDiv.innerText = "这是新的div";
    //3.找到页面上的一个节点
    var rootDiv = document.getElementsByTagName('div')[0];
    console.log(rootDiv);
    //4.将myDiv追加到rootDiv上
    rootDiv.appendChild(myDiv);
</script>

</html>